/**
 * @author Yura Zhloba
 * concise way to set padding
 * can be mixed to any class which has properties "paddingLeft", "paddingRight", "paddingTop", "paddingBottom"
 */

//noinspection JSUnusedGlobalSymbols
public function set padd(value : String) : void
{
	var values : Array = value.split(",");

	if(values.length == 1)
	{
		paddingLeft = paddingTop = paddingRight = paddingBottom = validatePadd(values[0]);
	}
	else if(values.length == 2)
	{
		paddingLeft = paddingRight = validatePadd(values[0]);
		paddingTop = paddingBottom = validatePadd(values[1]);
	}
	else
	{
		paddingLeft = validatePadd(values[0]);
		paddingTop = validatePadd(values[1]);
		paddingRight = validatePadd(values[2]);
		paddingBottom = validatePadd(values[3]);
	}
}

private function validatePadd(value : String) : int
{
	if(!value) return 0;

	var res : int = parseInt(value);
	if(isNaN(res)) return 0;
	return res < 0 ? 0 : res;
}
